<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <input type="text" v-model="num">
        <button v-on:click="num++">点赞</button>
        <button v-on:click="cancel" v-if="num>0">取消点赞</button>
        <h1>{{name}}，你好！有{{num}}个人点赞！</h1>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        // 声明式渲染
        let vm = new Vue({
            el: "#app", // 绑定元素
            data: {
                name: "张三",
                num: 1
            },
            // 封装方法
            methods: {
                cancel() {
                    this.num--;
                }
            }
        });
    </script>
</body>

</html>